import socket

serversocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

# 获取本地主机名
host = socket.gethostname()

port = 9999

#绑定端口号
serversocket.bind((host,port))

#设置最大连接数，超时排队
serversocket.listen(5)

while True:
    #建立客户端连接
    clientsocker,addr = serversocket.accept()

    print("连接地址为:%s" % str(addr))

    msg = "欢迎访问菜鸟网络"
    clientsocker.send(msg.encode("UTF-8"))
    clientsocker.close()

